package cn.itcast.chapter08.filter;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

public class MyFilter implements Filter {
    public void destroy(){
        //过滤器在对象销毁时自动调用，释放资源
    }
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        //用于拦截用户请求，如果和当前过滤器的拦截路径匹配，该方法会被调用
        PrintWriter out = response.getWriter();
        out.write("Hello MyFilter---------");
    }
    public void init(FilterConfig fConfig)throws  ServletException{
        //过滤器对象在初始化时调用，可以配置一些初始化参数
    }


}
